<template>
  <div>
    <div style="text-align: center">
      <el-input placeholder="请输入内容" v-model="inputSearch" class="input-with-select" style="width: 400px">
        <el-button slot="append" icon="el-icon-search" @click="handleSearch"></el-button>
      </el-input>
      <div style="width: 400px; margin: auto;border: black 1px solid">
        <div v-for="(item, index) in searchList" style="text-align: left; margin-top: 5px">
          {{ item }}
        </div>
      </div>
    </div>
    <div style="margin-top: 50px">
      <el-row>
        <!--视频-->
        <el-col :span="20" :offset="2">
          <div v-for="(item, index) in videoList" style="display: inline-block; margin-bottom: 30px; margin-right: 5px"  @click="$router.push(`/video/${item.id}`)">
            <img :src="item.videoCover" style="width: 300px; height: 168px">
            <div style="font-size: 15px"> {{ item.videoName }} </div>
            <br>
            <div style="font-size: 13px"> {{ item.videoAuthor }} - {{ item.videoDate }} </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { listVideo } from '@/api/video'

export default {
  name: 'searchVideo',
  data () {
    return {
      searchList: ['测试1', '测试2', '测试3', '测试'],
      inputSearch: '',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        videoName: null,
        videoType: null,
        videoIndex: null,
        videoCount: null,
        videoPath: null,
        videoAuthor: null,
        videoDate: null,
        videoTime: null,
        status: 1
      },
      videoList: []
    }
  },
  async created () {
    this.inputSearch = this.$route.params.searchText

    this.queryParams.videoName = this.inputSearch

    const res = await listVideo(this.queryParams)
    this.videoList = res.data.rows
  },
  methods: {
    async handleSearch () {
      this.queryParams.videoName = this.inputSearch

      const res = await listVideo(this.queryParams)
      this.videoList = res.data.rows
    }
  }
}
</script>

<style scoped lang="less">

</style>
